<template>
  <div
    class="cinema-wrapper"
    ref="cinema-wrapper"
    :style="{ height: height + 'px' }"
  >
    <ul class="cinema-list">
      <slot></slot>
    </ul>
  </div>
</template>

<script>
//引入better-scroll插件（移动端滚动功能插件）
import BetterScroll from "better-scroll";
export default {
  data() {
    return {
      height: 400,
      bs: null,
    };
  },
  props: ["cinemas", "getData"],
  mounted() {
    // 列表内容高度 = 当前屏幕可见区高度 - 底部菜单高度 - 顶部高度
    const h = document.documentElement.clientHeight - 100;
    this.height = h;

    this.$nextTick(() => {
      this.bs = new BetterScroll(this.$refs["cinema-wrapper"], {
        // 默认会取消点击事件 click事件在移动站点中有300ms延时
        click: true,
        // 组件提供了一个解决延时问题配置 默认会给组件添加一个@tap事件
        tap: "tap",
        //开启下拉刷新事件
        pullDownRefresh: true,
        // 拖到底部时，触发事件
        pullUpLoad: true,
        mouseWheel:true
      });
      // 下拉加载事件
      this.bs.on("pullingDown", () => {
        console.log("下拉加载");
        this.getData();
        this.bs.finishPullDown();
      });
      // 拖到底部时触发
      this.bs.on("pullingUp", () => {
        console.log("拖到底部触发");
        this.getData();
        this.bs.finishPullUp();
      });
    });
  },
  beforeDestroy() {
    this.bs = null;
  },
  
};
</script>

<style lang="scss">
.cinema-wrapper {
  background: #fff;
  overflow: hidden;
  height: 400px;
  margin-top: 100px;
  .cinema-list {
  padding-bottom: 50px;
  z-index: 1;
}
}
</style>